package com.technology.education.ui.teacher.deposit

import androidx.lifecycle.MutableLiveData
import com.technology.education.data.AppData
import com.technology.education.data.SpKeys
import com.technology.education.data.model.DurationWithdrawModel
import com.technology.education.data.model.UserInfoModel
import com.technology.education.ext.getAppViewModel
import com.technology.education.ext.saveData
import com.technology.education.ext.toast
import com.technology.education.network.apiService
import me.hgj.jetpackmvvm.base.viewmodel.BaseViewModel
import me.hgj.jetpackmvvm.ext.request
import me.hgj.jetpackmvvm.state.ResultState

/**
 *@author:create by BZY
 *Date: 2022/3/1 13
 */
class DepositViewModel : BaseViewModel() {
    val notify = "1.保证金的金额为500元，在缴纳完保证金后方\n" +
            "可进行订单的接收与辅导\n" +
            "2. 保证金是为了保证辅导过程的有序进行，不\n" +
            "作为其他使用\n" +
            "3.保证金可申请退回，退回后不能在平台进行\n" +
            "接单辅导，申请退回后七个工作日内退回\n" +
            "4.在违反平台《辅导员辅导规范》时，平台有\n" +
            "权利对保证金进行一定的扣除\n" +
            "5.当保证金因辅导员违反《辅导员辅导规范》\n" +
            "扣除余额不足300元时，将不可进行接单辅导"
    val result = MutableLiveData<ResultState<DurationWithdrawModel>>()
    val info = MutableLiveData<UserInfoModel>()

    /**
     * 提交支付订单
     */
    override fun getData() {
        super.getData()
        request({ apiService.userInfo() }, success = {
            getAppViewModel().userInfo.postValue(it)
            info.postValue(it)
        }, error = {
            toast(it.errorMsg)
        })

    }

    fun commitOrder() {
        request({ apiService.placeDepositOrder() }, result, isShowDialog = true)
    }

}